package com.itheima.consumer.controller;

import com.itheima.consumer.client.UserClient;
import com.itheima.consumer.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * feign中也是集成了ribbon服务，首先使用的是feign内置的因此不需要额外引入依赖，也不需要再注册 RestTemplate 对象(发送请求并将返回的结果进行序列化java与json之间的转换)
 */
@RestController
@RequestMapping("/cf")
public class ConsumerFeignController {

    @Autowired
    public UserClient userClient;//需要在引导类上面加注解 开启Feign客户端功能

    @GetMapping("/{id}")
    public User queryById(@PathVariable Long id) {
        return userClient.queryById(id);
    }
}
